package com.lenovo.nova.widget.baseview;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.NetworkInfo;
import android.util.AttributeSet;
import android.widget.Button;
import com.lenovo.nova.util.Applications;
import com.lenovo.nova.util.DevicesUtil;
import com.lenovo.nova.utils.R;


public class CustomButton extends Button implements Applications.OnInputModeChangeListener{

	public CustomButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initLayout(context,null);
	}

	public CustomButton(Context context, AttributeSet attrs) {
		super(context, attrs);
		initLayout(context,attrs);
	}

	public CustomButton(Context context) {
		super(context);
		initLayout(context,null);
	}

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        Applications.get(getContext()).addOnInputModeChangeListener(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        Applications.get(getContext()).removeOnInputChangeListener(this);
    }

    private void initLayout(Context context, AttributeSet attrs) {
		
	}

    @Override
    public void onInputModeChange(boolean isInTouchMode) {
        if(isInTouchMode){
            DevicesUtil.getInstance().ensureInputMode(this);
        }else {
            setHovered(false);
        }
    }
}
